<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>申请驳回</title>
    <script src="../layui/layui.js"></script>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <script src="../src/static/jquery.js"></script>
</head>
<body>
<div style="font-size: 20px;text-indent: 6em;margin-top: 3%;margin-bottom: 3%">请选择不符原因</div>
    <form class="layui-form" >
        <div class="layui-form-item">
            <div class="layui-input-inline" style="margin-left: 100px" id="company">
                <input type="checkbox" name="test" id="#r1" value="1" title="公司外景照不清晰" required="required">
                <input type="checkbox" name="test" value="2" title="公司内景照不清晰">
                <input type="checkbox" name="test" value="3" title="法人身份证与营业执照不一致">
                <input type="checkbox" name="test" value="4" title="公司名称与营业执照不一致">
                <input type="checkbox" name="test" value="5" title="公司地址与营业执照不一致">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" onclick="audit()" type="button">确定</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>



<script>
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]);
        return null;
    }
    var param = getQueryString('_ijt');

    //Demo
    layui.use('form', function () {
        var form = layui.form;
    });

    function audit() {
        var flg = check();
        if(flg == true){
            var obj = document.getElementsByName("test");
            var check_val="";
            for(var k in obj){
                if(obj[k].checked)
                    check_val+=obj[k].value+","
            }

            $.ajax({
                url: '/api/auditCompany',
                data: {id:param,status:2,reason:check_val},
                type: 'get',
                datatype: 'json',
                success: function (data) {
                    window.parent.location.href='/putIn/examine.html'
                },
                error: function (error) {
                    //请求失败  获取的报错信息
                    console.log(error);
                }
            })
        }else{
            layer.msg("输入向不能全为空！");
        }

    }
    //验证
    function check() {
        var obj = document.getElementsByName("test");
        var check_val = [];
        for(var k in obj){
            if(obj[k].checked)
                check_val+=obj[k].value+","
        }
       if(check_val == null || check_val == ""){
           return false;
       }
        return true;
    }
    
</script>
</body>
</html>